#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_log.h"
#include <string.h>
#include <inttypes.h>


#include "app_vars.h"
#include "w2p_auto_wifi.h"


static const char* TAG = "UART_COMM";


void app_main()
{
    esp_err_t err = nvs_flash_init();
if (err == ESP_OK) {
    // 初始化成功
    ESP_LOGI(TAG,"NVS flash initialized successfully\n");
} else if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
    // NVS 分区需要擦除
    ESP_LOGI(TAG,"need swipe out flash.");
    ESP_ERROR_CHECK(nvs_flash_erase());
    err = nvs_flash_init();
    ESP_ERROR_CHECK(err);
} else {
    // 其他错误
    ESP_ERROR_CHECK(err);
}
    initAppConfiguration();    
    auto_wifi_app_main();
            
}